<?php include('GA.inc.php');?>
<?php $baseUrl = Yii::app()->request->baseUrl;?>
<?php 
   $categories = array();
   $criteria = new CDbCriteria();
   $criteria->addCondition('active = 1');
   $criteria->addNotInCondition('id',array(26));
   $criteria->order = 'parent_id ASC, position ASC';
   $list = Category::model()->findAll($criteria);
   //CVarDumper::dump($list,10,true);die();
   foreach($list as $key=>$value){
      $sub = array();
      if($value->parent_id > 0){
         $tmp['id'] = $value->id;
         $tmp['name'] = $value->name;
         $categories[$value->parent_id]['sub'][] = $tmp;
         unset($list[$key]);
      }else{
         $tmp['id'] = $value->id;
         $tmp['name'] = $value->name;
         $tmp['position'] = $value->position;
         $categories[$value->id] = $tmp;
      }
   }
   
   //CVarDumper::dump($categories,10,true);die();
   foreach($list as $key=>$value){
      $categories[$value->id]['id'] = $value->id;
      $categories[$value->id]['position'] = $value->position;
      $categories[$value->id]['name'] = $value->name;
   }
   
   //CVarDumper::dump($categories,10,true);die();
?>

<div class="container">
   <div class="slogan">
      <span>Trang tổng hợp tin tức bóng đá 24/7</span>
   </div>
   <div class="top-header text-right">
      <div id="logo" class="left">
         <a href="/">
            <img alt="" src="<?php echo $baseUrl.'/images/logo.png'?>" />
         </a>
      </div>
      <span class="date-time solar">
      <?php $wday = array('Chủ nhật','Thứ hai','Thứ ba','Thứ tư','Thứ năm','Thứ sáu','Thứ bảy');
         $today = getdate();
         echo $wday[$today['wday']] . ', ngày ' . $today['mday'] . ' tháng ' . $today['mon'] . ' năm ' . $today['year'];
      ?>
      </span>
      <br />
      <span class="date-time lunar">
         <?php 
            $lunar = MyDatetime::getchinesedate($today['year'],$today['mon'],$today['mday']);
            $lunar_year = array(2014 => 'Giáp Ngọ',2015 => 'Ất Mùi',2016 => 'Bính Thân');
            echo 'Âm lịch: Ngày ' . $lunar[2] . ' tháng ' . $lunar[1] . ' năm ' . $lunar_year[$lunar[0]];   
         ?>
      </span>
         
   </div>
   <div class="clear"></div>
   
   <div class="main-menu">
      <ul class="parent-menu">
         <li class="menu-item">
            <a href="<?php echo Yii::app()->request->baseUrl;?>/">Trang chủ</a>
         </li>
         <?php foreach($categories as $item){
            //CVarDumper::dump($item,10,true);die();
            
            $link = Category::model()->getLink($item['id'],$item['name']);
            ?>
            <li class="menu-item">
               <a href="<?php echo $link?>"><?php echo $item['name']?></a>
               <?php if(isset($item['sub'])){
                  $sub = $item['sub'];?>
                     <span class="sub-indicator"></span>
                     <ul class="sub-menu">
                        <?php foreach($sub as $sub_item){
                           $link_sub = Category::model()->getLink($sub_item['id'],$sub_item['name'],$item['name']);
                           //CVarDumper::dump($sub_item,10,true);die();
                           ?>
                           <li class="menu-item">
                              <a href="<?php echo $link_sub?>"><?php echo $sub_item['name']?></a>
                           </li>
                        <?php }?>
                     </ul>
                     
                  <?php 
               }?>
            </li>
         <?php }?>
         
      </ul>
   </div>
</div>
